/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Implementation.SourceCode.Utilities;

import java.io.File;
import java.util.Locale;
import jxl.CellView;
import jxl.Range;
import jxl.Workbook;
import jxl.WorkbookSettings;
import jxl.format.UnderlineStyle;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
/**
 *
 * @author apple
 */
public class WriteExcelTest {
    private static WritableCellFormat timesBoldUnderline;
    private static WritableCellFormat times;

    public static void main(String a[]){
        try{
            WriteExcel123 test = new WriteExcel123();

            File f = new File("d:\\excel.xls");
            WorkbookSettings wbSettings = new WorkbookSettings();
            wbSettings.setLocale(new Locale("en", "EN"));
            WritableWorkbook workbook = Workbook.createWorkbook(f, wbSettings);
            workbook.createSheet("Chi Văn Phòng", 0);
            WritableSheet excelSheet = workbook.getSheet(0);


            WritableFont times10ptBoldUnderline = new WritableFont(
				WritableFont.TIMES, 10, WritableFont.BOLD, false,
				UnderlineStyle.SINGLE);
            timesBoldUnderline = new WritableCellFormat(times10ptBoldUnderline);


		WritableFont times10pt = new WritableFont(WritableFont.TIMES, 10);
		// Define the cell format
		times = new WritableCellFormat(times10pt);
		// Lets automatically wrap the cells
		times.setWrap(true);
		timesBoldUnderline = new WritableCellFormat(times10ptBoldUnderline);
		// Lets automatically wrap the cells
		timesBoldUnderline.setWrap(true);

		CellView cv = new CellView();
		cv.setFormat(times);
		cv.setFormat(timesBoldUnderline);
		cv.setAutosize(true);
            Label label;
            label = new Label(0, 0, "BÁO CÁO CHI THÁNG 5_2011", timesBoldUnderline);
            excelSheet.addCell(label);
            excelSheet.mergeCells(0, 0, 4, 0);


            workbook.write();
            workbook.close();

            test.write();
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }
}
